# -*- coding:utf-8 -*-
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
# 根据实际的包结构去引入
from com.micro.thriftDemo import HelloWorldService


# test.thrift的具体实现
class TestServiceHandler:
    def __init__(self):
        self.log = {}

    # ----------------接口方法实现---------------------
    def sayHello(self, name):
        print("Input value:" + name)
        return 'hello  world! i am isiteam Iface lixianglong'

if __name__ == '__main__':
    handler = TestServiceHandler()
    processor = HelloWorldService.Processor(handler)
    transport = TSocket.TServerSocket(host='127.0.0.1', port=9090)  # localhost
    # transport = TSocket.TServerSocket(host='localhost', port=9090) # localhost

    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()

    server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
    print('python server:ready to start')
    server.serve()

